nanopyx.liquid._le_mandelbrot_benchmark

class MandelbrotBenchmark(nanopyx.liquid.__liquid_engine__.LiquidEngine):

Mandelbrot Benchmark using the NanoPyx Liquid Engine

MandelbrotBenchmark(clear_benchmarks=False, testing=False)

Initialize the Liquid Engine The Liquid Engine base class is inherited by children classes that implement specific methods

Engine responsabilities:

  1. Store implemented run types;
  2. Handle previous benchmarks and I/O;
  3. When queried, benchmark all available run types;
  4. Run a specific method using a selected run type;

Benchmark files have the following format: The benchmark file is read as dict of dicts. BENCHMARK DICT FOR A SPECIFIC METHOD |- RUN_TYPE #1 | |- ARGS_REPR #1 | | |- [score, t2run#1, t2run#2, t2run#3, ...] last are newer. nan means fail | |- ARGS_REPR #2
| | |- [score, t2run#1, t2run#2, t2run#3, ...] last are newer. nan means fail | (...) |- RUN_TYPE #2 (...)

def benchmark(self, size, r_start=-1.5, r_end=0.5, c_start=-1.0, c_end=1.0):
  1. Run each available run type and record the run time and return value
  2. Sort the run times from fastest to slowest
  3. Compare each run type against each other, sorted by speed
Parameters
  • args: args for the run method
  • kwargs: kwargs for the run method
Returns

a list of tuples containing the run time, run type name and optionally the return values

def run( self, size=1000, r_start=-1.5, r_end=0.5, c_start=-1.0, c_end=1.0) -> numpy.ndarray:

Run the mandelbrot benchmark

Parameters
  • size: Size of the image to generate (size x size)
  • r_start: Start of the row axis
  • r_end: End of the row axis
  • c_start: Start of the column axis
  • c_end: End of the column axis
Returns

The mandelbrot set as a numpy array